/**
  **************************************************************************
  * @file     at32f435_437_int.c
  * @version  v2.1.0
  * @date     2022-08-16
  * @brief    main interrupt service routines.
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

/* includes ------------------------------------------------------------------*/
#include "at32f435_437_int.h"
#include <string.h>
#include <stdio.h>
#include "i2c_application.h"

extern void bat_display(void);

extern i2c_handle_type hi2cx;

static uint8_t exint_cnt = 0;
/** @addtogroup AT32F437_periph_examples
  * @{
  */

/** @addtogroup 437_SPI_crc_transfer_polling
  * @{
  */

/**
  * @brief  this function handles nmi exception.
  * @param  none
  * @retval none
  */
void NMI_Handler(void)
{
}

/**
  * @brief  this function handles hard fault exception.
  * @param  none
  * @retval none
  */
void HardFault_Handler(void)
{
  /* go to infinite loop when hard fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles memory manage exception.
  * @param  none
  * @retval none
  */
void MemManage_Handler(void)
{
  /* go to infinite loop when memory manage exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles bus fault exception.
  * @param  none
  * @retval none
  */
void BusFault_Handler(void)
{
  /* go to infinite loop when bus fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles usage fault exception.
  * @param  none
  * @retval none
  */
void UsageFault_Handler(void)
{
  /* go to infinite loop when usage fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles svcall exception.
  * @param  none
  * @retval none
  */
//void SVC_Handler(void)
//{
//}

/**
  * @brief  this function handles debug monitor exception.
  * @param  none
  * @retval none
  */
void DebugMon_Handler(void)
{
}

///**
//  * @brief  this function handles pendsv_handler exception.
//  * @param  none
//  * @retval none
//  */
//void PendSV_Handler(void)
//{
//}

///**
//  * @brief  this function handles systick handler.
//  * @param  none
//  * @retval none
//  */
//void SysTick_Handler(void)
//{

//  TimeFrame_TIMECNT();
//	

//}


/**
 * @brief  this function handles usart1 handler.  DVR
 * @param  none
 * @retval none
 */
void USART1_IRQHandler(void)
{
	uint8_t clear;
	
	if(usart_flag_get(USART1, USART_RDBF_FLAG) != RESET)			// USART1接收中断响应
	{
		// USART1读取数据寄存器		
//		dmc_rx_buf[dmc_rx_cnt++] = USART1->dt;
	}
	if(usart_flag_get(USART1, USART_IDLEF_FLAG) != RESET)           // USART1总线空闲
	{
		clear = USART1->sts;										// USART1清除空闲中断标志位
		clear = USART1->dt;											// USART1清除空闲中断标志位
		clear &= 0;
//		DMC_Parse( );
//		dmc_rx_cnt = 0;
	}
}

/**
 * @brief  this function handles usart5 handler.
 * @param  none
 * @retval none
 */
void USART5_IRQHandler(void)
{
//	uint8_t clear;
//	if(usart_flag_get(UART5, USART_RDBF_FLAG) != RESET)			// USART3接收中断响应
//	{
//		gps_rx_buf[gps_rx_cnt++] = UART5->dt;					// USART3读取数据寄存器		
//	}
// 
//	if(usart_flag_get(UART5, USART_IDLEF_FLAG) != RESET)		// USART3总线空闲
//	{
//		clear = UART5->sts;										// USART3清除空闲中断标志位
//		clear = UART5->dt;										// USART3清除空闲中断标志位
//		clear &= 0;
//		if(GPS_RMC_Parse(gps_rx_buf,&GPS_Info) != 1)
//		{
//			memset(gps_rx_buf,0x00,UART5_GPS_BUFF_SIZE);
//		}
//		gps_rx_cnt = 0;
//	}

}


/**
  * @brief  exint11 interrupt handler
  * @param  none
  * @retval none
  */


//void ADC1_2_3_IRQHandler(void)
//{
//	if(adc_flag_get(ADC1, ADC_OCCO_FLAG) != RESET)
//	{
//		adc_flag_clear(ADC1, ADC_OCCO_FLAG);
//		
//	}
//}




